Skip to content

fix(mcp): load every page of tools/list - #81

Open
pcbeingused33 wants to merge 1 commit into
fim-ai:masterfrom
pcbeingused33:fix/mcp-tools-list-pagination
Open

pcbeingused33 wants to merge 1 commit into
fim-ai:masterfrom
pcbeingused33:fix/mcp-tools-list-pagination

Conversation

@pcbeingused33

Copy link
Copy Markdown
Contributor

What

MCPClient now follows nextCursor when listing a server's tools, on all three transports (stdio, SSE, Streamable HTTP).

Why

tools/list is paginated in the MCP spec. connect_stdio, connect_sse and connect_streamable_http each called session.list_tools() once and built adapters from that first answer, so with a server that pages its list, every tool after page one was missing from the agent, with no error or log line.

The three call sites now share _list_all_tools(), which requests pages until the cursor is absent (an empty string is still a cursor). A server that hands back a cursor already used ends the listing with a warning, and tools are keyed by name so a repeated page does not fail registration. The listing stays inside the existing try, so a failure on a later page is cleaned up like one on the first.

Type

  • Bug fix

Tests

tests/test_mcp_tool_pagination.py covers a three-page listing on each transport and the repeated-cursor case; all four fail without the change. Also checked against a stdio server built with the SDK that serves one tool per page: a single call returned t0, the new helper returns t0, t1, t2.

Added one line under [Unreleased] / Fixed in docs/changelog.mdx.

Checklist

  • uv run ruff check src/ tests/ passes (the changed files pass; the repo-wide run reports existing errors in other files)
  • uv run pytest passes (the MCP tests pass; the full suite was not run to completion)
  • cd frontend && pnpm build passes (no frontend changes)
  • i18n strings added to both en/ and zh/ (no UI text changed)
  • Tests added for new functionality

This change was prepared with the help of an AI coding assistant.

@mintlify

mintlify Bot commented Nov 27, 2026

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 2b047c0.

Approve preview

tao-hpu commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Thanks, this is a good catch, and the tests cover all three transports. Since it changes how every MCP server's tools get loaded, I'd like to review it myself and get CI green before merging. The one failure on Python 3.13 (test_workflow_suspend_hardening.py) looks unrelated to your change, and I'll check it on my side. I'll follow up here soon.


Generated by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants